s = input()
st = []
aa = ['(', '[', '{', '<']
bb = [')', ']', ' }', '>']

for c in s:
    if c in aa:
        st.append(c)
    elif c in bb:
        if not st or bb[aa.index(st.pop())] != c:
            print(False)
            break
else:
    print(not st)
